<%-- 
    Document   : agregarColumnas
    Created on : Feb 22, 2012, 1:22:04 AM
    Author     : andreth
--%>
<% String CPYD = "CPYD";%>
<% Matriz m = (Matriz) request.getAttribute("Matriz");
    String codigoUnidad = m.getCodigoUnidad();
 //  request.setAttribute("Matriz", m);
   // out.print(m.getNumeroColumnas());%>
<%@page import="clases.Matriz"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>   <script language="javascript" src="/CPYD/interfaz/javascript/matrices.js"></script>
    <tiles:insert definition="mensaje"></tiles:insert>
    <logic:present name="Matriz">
        <h1><bean:write name="Matriz" property="nombre"></bean:write></h1>
        <table>
            <tr>
                <td><strong>Unidad:</strong></td>
                <td><bean:write name="Matriz" property="codigoUnidad"></bean:write></td>
            </tr>
            <tr>
                <td><strong>Numero Columnas:</strong></td>
                <td><bean:write name="Matriz" property="numeroColumnas"></bean:write></td>
            </tr>
        </table>

        </logic:present>
    <hr>
    <h2>Agregar columnas de la matriz</h2>

    <logic:present name="Matriz" property="idMatriz">
        <logic:present  name="Matriz" property="codigoUnidad">
            <html:form action="/agregarDescripcion?method=save" onsubmit="return this">
                <html:hidden name="Matriz" property="codigoUnidad"/>
                <html:hidden name="Matriz" property="nombre"/>                
                <html:hidden name="Matriz" property="idMatriz"/>
                  <html:hidden name="Matriz" property="numeroColumnas"/>
                <div id="tableContainer" class="tableContainer">
                    <table id="tabla" cellpadding="0" cellspacing="0" width="70%" border=0 class="scrollTable">
                        <tbody class="scrollContent">
                            <tr >
                                <td> Nombre Columna </td>
                                <logic:iterate name="Matriz" property="columnas" id="columna" >
                                    <td><html:text name="columna" property="nombre" indexed="true" onblur="validarAlfanumerico(this.value)"></html:text> 
                                       
                                    </td> 
                                </logic:iterate>
                                    <td>*</td>
                            </tr>
                            <tr>
                                <td> Tipo </td>
                                <logic:iterate name="Matriz" property="columnas" id="columna" indexId="contador" >
                                    <%
                                        Integer counter = (Integer) pageContext.getAttribute("contador");%>

                                    <td> <html:select name="columna" property="tipo" indexed="true" onchange='<%= "mostrarListas(this, " + counter.intValue() + ")"%>'>
                                            <html:option value="0"> Seleccione un tipo</html:option>
                                            <html:options name="tipos"/>
                                        </html:select>    
                                    
                                    </td>

                                </logic:iterate>    
                                     <td>*</td>
                            </tr>
                            <tr>
                                <td>Lista</td>

                                <logic:iterate name="Matriz" property="columnas" id="columna" >
                                    <td>
                                        <html:select disabled="true" name="columna" property="idLista" indexed="true">
                                            <html:option value="0">Seleccionar lista</html:option>
                                            <html:options collection="listas" labelProperty="nombre" property="idLista"></html:options>
                                        </html:select>
                                      
                                    </td>
                                </logic:iterate>  
                                  <td>*</td>

                            </tr>
                            <tr>
                                <td> Unidad Responsable</td>
                                <logic:iterate name="Matriz" property="columnas" id="columna" >
                                    <td><html:select name="columna" property="cpyd" indexed="true">
                                            <html:option value="0"> Seleccione Unidad Responsable</html:option>
                                            <html:option value="<%= CPYD%>"> CPYD </html:option>
                                            <html:option value="<%= codigoUnidad%>"> 
                                                <bean:write name="Matriz" property="codigoUnidad"/> </html:option>
                                        </html:select> 
                                       
                                    </td>
                                </logic:iterate>
                                     <td>*</td>
                            </tr>
                            <tr>
                                <td> Cantidad Filas </td>
                                <td><html:text name="Matriz" property="numeroFilas" onblur="validarNumerico(this.value)"/>
                                   
                                </td>
                                 <td>*</td>
                            </tr>
                        </tbody>
                        <tiles:insert definition="campoObligatorio"></tiles:insert>
                    </table>
                    <div class="buttons">
                        <button type="submit" class="positive" >
                            <img src="interfaz/images/guardar.png" alt=""/>
                            Guardar Descripcion Matriz
                        </button>   
                    </div>
                </div>   
            </html:form>
        </logic:present>
    </logic:present>   

    <br>
    <hr>

</html>

<!--      CODIGO DE COLUMNAS DINAMICAS
 
                                    <td>
                                        <button type="submit" class="positive" onclick="agregarColumna();">
                                            <img src="/CPYD/interfaz/images/agregar.png" alt=""/>
                                            Agregar Columna
                                        </button>
                                    </td>
                                    <td>
                                        <button type="submit" id="boton" class="negative" onclick="eliminarColumna();">
                                            <img src="/CPYD/interfaz/images/eliminar.png" alt=""/>
                                            Eliminar Columna
                                        </button>
                                    </td>-->
